package cn.edu.bcu.ls.controller;

import cn.edu.bcu.ls.entity.Song;
import cn.edu.bcu.ls.service.SongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SongController {
    @Autowired
    private SongService songService;


    @PostMapping(value = "Song")
    public boolean InsertSong(Song song) {
        return songService.insertSelective(song) > 0 ? true : false;
    }

    @DeleteMapping(value = "Song")
    public boolean deleteSong(Integer song_id) {
        return songService.deleteByPrimaryKey(song_id) > 0 ? true : false;
    }

    @PutMapping(value = "Song")
    public boolean updateSong(Song song) {
        return songService.updateByPrimaryKeySelective(song) > 0 ? true : false;
    }

    @GetMapping(value = "Song")
    public List<Song> getSong(@RequestParam(required = false) Integer song_id) {
        return songService.selectByPrimaryKey(song_id);
    }
}
